package org.lql.algo.codecrush.week007;

/**
 * @author: liangqinglong
 * @date: 2025-08-18 13:49
 * @description: 69. x 的平方根 <a href="https://leetcode.cn/problems/sqrtx/description/">...</a>
 **/
public class MySqrt {

	public int mySqrt(int x) {
		int left = 0;
		int right = x;
		while (left < right) {
			int mid = (left + right + 1) / 2;
			if (mid <= x / mid) {
				left = mid;
			} else {
				right = mid - 1;
			}
		}
		return right;
	}

	public static void main(String[] args) {
		MySqrt mySqrt = new MySqrt();
		System.out.println(mySqrt.mySqrt(8));
	}
}
